import { Column, Entity, ManyToOne, PrimaryGeneratedColumn } from "typeorm";
import { Role } from "@/modules/system/role/entities/role.entity";
import { Menu } from "@/modules/system/menu/entities/menu.entity";
import { TABLE_PREFIX } from '@/config';

@Entity({name:`${TABLE_PREFIX}sys_role_menu`})
export class RoleMenu {
    @PrimaryGeneratedColumn({ type: "bigint" })
    id: string;
    
    @Column({ type: "int", name: "roleId", comment: "角色 id" })
    roleId: number;
    
    @Column({ type: "int", name: "menuId", comment: "菜单 id" })
    menuId: number;
    
    @ManyToOne(() => Menu, (menu) => menu.id, { onDelete: "CASCADE" })
    menu: Menu;
    
    @ManyToOne(() => Role, (role) => role.id, { onDelete: "CASCADE" })
    role: Role;
}